package model;

public strictfp class DoubleLevelSpec extends ParameterSpec {
	public double dMin;
	public double dMax;

	
	public DoubleLevelSpec(String name, double min, double max) {
		super(name);
		this.dMax = min;
		this.dMax = max;
	}

	public double getStep(int level)
	{
		double step =  (Math.abs(dMax - dMin) / level);
		return step;
	}
	
	
	private double enforceValidDouble(double d)
	{
		if (d < dMin)
			return dMin;
		else if (d > dMax)
			return dMax;
		else
			return d;		
	}

	/**
	 * Since this is a real-valued representation, the size of the search space
	 * becomes nearly infinite.  For now, we use the special value -1 for this case.
	 */
	@Override
	public long choiceCount()
	{
		return -1 ;
	}	

	@Override
	public String toString()
	{
		//return "[ \"" + name + "\" [ " + dMin +" " + dMax + " ] ]";
		return "[ " + name+"  [ " + dMin +" " + dMax + " ] ]";
	}

	@Override
	public Object getValueFromChoice(long choice, long maxNumChoices) {
		return dMin + (dMax - dMin) * choice / (maxNumChoices - 1);	
	}

}
